package com.test.pattern.memento.white_box;

/**
 * @ClassName: Client
 * @description:
 * @author: Mr du
 * @create: 2024-03-31 21:54
 */
public class Client {

    public static void main(String[] args) {
        System.out.println("------------大战Boss前------------");
        //大战Boss前
        GameRole gameRole = new GameRole();
        //首先初始化状态
        gameRole.initState();
        //展示内部状态
        gameRole.stateDisplay();
        //将该游戏内部状态进行备份
        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setRoleStateMemento(gameRole.saveState());

        System.out.println("------------大战Boss后------------");
        //大战Boss时，损耗严重
        gameRole.fight();
        //展示
        gameRole.stateDisplay();
        System.out.println("------------恢复之前状态------------");
        //恢复之前状态
        gameRole.recoverState(roleStateCaretaker.getRoleStateMemento());
        //展示
        gameRole.stateDisplay();
    }
}
